﻿<UserControl x:Class="FrontDisplay.Controls.ComboColorPicker"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:FrontDisplay.Controls"
    x:Name="ThisColorPicker">
    <UserControl.Resources>
        <DataTemplate DataType="{x:Type local:ColorViewModel}">
            <StackPanel Orientation="Horizontal" Margin="1">
                <Grid>
                    <!-- Draw a checkboard rectangle first, in case the selected color is transparent -->
                    <Rectangle Fill="{Binding ElementName=ThisColorPicker, Path=CheckerBrush}" Stroke="Black" SnapsToDevicePixels="True" Width="14" Height="14"/>
                    <!-- The actual color -->
                    <Rectangle Fill="{Binding Path=Brush}" Stroke="Black" SnapsToDevicePixels="True" Width="14" Height="14"/>
                </Grid>
                <!-- Name of the color -->
                <TextBlock Text="{Binding Path=Name}" Margin="4 0 4 0" VerticalAlignment="Center"/>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100*" />
            <ColumnDefinition Width="22" />
        </Grid.ColumnDefinitions>
        <ComboBox Name="ColorList" MinWidth="100" SelectedValue="{Binding ElementName=ThisColorPicker, Path=SelectedColor}" SnapsToDevicePixels="True">
        </ComboBox>
        <Button Grid.Column="1" Click="SelectColorButtonClick" HorizontalAlignment="Stretch" MaxHeight="22">...</Button>
    </Grid>
</UserControl>
